#ifndef __XORCRYPTOFACTORY_H__
#define __XORCRYPTOFACTORY_H__

#include "XORCrypto.h"

namespace encrypted
{
    namespace tunnel
    {

// The factory pattern(design pattern) of crypto.
// Used to generate the encryptor and decryptor.
// Can be replaced by another crypto factory.  Such as AESCryptoFactory/ECCCryptoFactory
        template<typename KeyBuffType>
        class XORCryptoFactory
        {
        public:
            typedef XORCrypto<KeyBuffType> Encryptor;
            typedef XORCrypto<KeyBuffType> Decryptor;
            typedef boost::shared_ptr<Encryptor> EncryptorPtr;
            typedef boost::shared_ptr<Decryptor> DecryptorPtr;
            XORCryptoFactory(KeyBuffType key, size_t keysize)
                : key(key), keysize(keysize)
            {
            }
            ~XORCryptoFactory()
            {
            }
            EncryptorPtr createEncryptor()
            {
                return EncryptorPtr(new Encryptor(key, keysize));
            }
            DecryptorPtr createDecryptor()
            {
                return DecryptorPtr(new Decryptor(key, keysize));
            }
        private:
            KeyBuffType key;
            size_t keysize;
        };
    }
}
#endif
